<template>
  <div class="hello">
    <h1>{{ msg }}</h1>
    <a href="javascript:;" @click="btn">发送请求</a>
    <p>{{ count }}</p>
  <p>
    <button @click="increment">+</button>
    <button @click="decrement">-</button>
  </p>
  <parent-page/>
  <Home></Home>
  </div>
</template>
<script>
import API from '@/api/requestModule/login.js'
import md5 from 'js-md5'
import { mapState, mapActions } from 'vuex'
import ParentPage from '../components/Parents'
import Home from "@/components/Home"
export default {
  components: {
    ParentPage,
    Home
  },
  computed: mapState([
    'count'
  ]),
  methods:mapActions([
    ]),
  data () {
    return {
      msg: 'Welcome to Your Vue.js App',
      num: null

    }
  },
  mounted () {
    console.log(6666)
    console.log(this.$store.state.count)

    let id = this.randomString_s_click(20)
    console.log(id)
  },
  methods: {
    randomString_s_click(len) {
    len = len || 32;
    let chars = "ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678";
    let maxPos = chars.length;
    let pwd = "";
    for (let i = 0; i < len; i++) {
        pwd += chars.charAt(Math.floor(Math.random() * maxPos));
    }
    return pwd + "_" + Math.round(new Date().getTime() / 1000);
  },
    btn () {
      let data = { username: 'dqadmin', password: md5('123456') }
      API.login(data).then((res) => {
        console.log(res)
      })
    },
    increment () {
      this.$store.commit('increment')
    },
    decrement () {
      this.$store.commit('decrement')
    }

  }
}

</script>
